﻿using System;

namespace Entities
{
    [Serializable]
    public class tblProduct
    {
        private string product_name;
        private string product_des;
        private int product_quantity;
        private string product_unit;
        private string image;
        private int manufacturer_id;
        private int price;
        private DateTime date_available;
        private DateTime date_added;
        private DateTime date_modified;
        private bool status;

        public tblProduct() {}

        public tblProduct(string product_name, string product_des, int product_quantity, string product_unit, string image, int manufacturer_id, DateTime date_available, DateTime date_added, DateTime date_modified, int price, bool status)
        {
            this.product_name = product_name;
            this.product_des = product_des;
            this.product_quantity = product_quantity;
            this.product_unit = product_unit;
            this.image = image;
            this.manufacturer_id = manufacturer_id;
            this.price = price;
            this.date_available = date_available;
            this.date_added = date_added;
            this.date_modified = date_modified;
            this.status = status;
        }

        public string productName
        {
            get { return this.product_name; }
            set
            {
                if (value == null)
                    throw new Exception("Tên sản phẩm không được để trống!");
                this.product_name = value;
            }
        }

        public string productDes
        {
            get { return this.product_des; }
            set
            {
                this.product_des = value;
            }
        }

        public int productQuantity
        {
            get { return this.product_quantity; }
            set
            {
                if (value == null)
                    throw new Exception("Số lượng sản phẩm không được để trống!");
                this.product_quantity = value;
            }
        }

        public string productUnit
        {
            get { return this.product_unit; }
            set
            {
                this.product_unit = value;
            }
        }

        public string Image
        {
            get { return this.image; }
            set
            {
                this.image = value;
            }
        }

        public int manufacturerID
        {
            get { return this.manufacturer_id; }
            set
            {
                if (value == null)
                    throw new Exception("Mă nhà sản xuất không được để trống!");
                this.manufacturer_id = value;
            }
        }

        public int Price
        {
            get { return this.price; }
            set
            {
                this.price = value;
            }
        }

        public DateTime dateAvailable
        {
            get { return this.date_available; }
            set
            {
                this.date_available = value;
            }
        }

        public DateTime dateAdded
        {
            get { return this.date_added; }
            set
            {
                this.date_added = value;
            }
        }

        public DateTime dateModified
        {
            get { return this.date_modified; }
            set
            {
                this.date_modified = value;
            }
        }

        public bool Status
        {
            get { return this.status; }
            set
            {
                if (value == null)
                    throw new Exception("Trạng thái sản phẩm không được để trống!");
                this.status = value;
            }
        }

        public override string ToString()
        {
            return this.product_name + "; " + this.product_des + "; " + this.product_quantity + "; " + this.product_unit + "; " + this.image + "; " + this.manufacturer_id + "; " + this.price + "; " + this.date_available + "; " + this.date_added + "; " + this.date_modified + "; " + this.status + "; ";
	    }
	    public override bool Equals(Object obj)
	    {
            tblProduct me = (tblProduct)obj;
	        bool ret=this.productName.Equals(me.productName);
	        return ret;
	    }
	    public override int GetHashCode()
	    {
	        return this.productName.GetHashCode();
	    }

    }
}
